// @ts-nocheck
const winston = require("winston");
const DailyRotateFile =require("winston-daily-rotate-file");
const customFormat = winston.format.combine(
    winston.format.timestamp({ format: "MMM-DD-YYYY HH:mm:ss" }),
    winston.format.align(),
    winston.format.printf(({level,timestamp,message,meta}) =>{
        return `${level}:
        Time:${[timestamp]}
        Url:${meta.req.url}
        Method:${meta.req.method}
        headers:${JSON.stringify(meta.req.headers)}
        httpVersion:${meta.req.httpVersion}
        originalUrl:${meta.req.originalUrl}
        query:${JSON.stringify(meta.req.query)}
        Message:${message}
        body:${JSON.stringify(meta.req.body)}
        ip:${meta.req.ip}`
    })
);
const defaultOptions = {
    format: customFormat,
    datePattern: "YYYY-MM-DD",
    zippedArchive: true,
    maxSize: "20m",
    maxFiles: "14d",
};
const globalLogger = winston.createLogger({
    format: customFormat,
    transports: [
        new DailyRotateFile({
            filename: "logs/info-%DATE%.log",
            level: "info",
            ...defaultOptions,
        }),
        new DailyRotateFile({
            filename: "logs/error-%DATE%.log",
            level: "error",
            ...defaultOptions,
        }),
    ],
});

const authLogger = winston.createLogger({
    transports: [
        new DailyRotateFile({
            filename: "logs/authLog-%DATE%.log",
            ...defaultOptions,
        }),
    ],
});

module.exports = {
    globalLogger: globalLogger,
    authLogger: authLogger,
};